%% term_rot_Wold_grad_T_G
function matrix_A = term_rot_Wold_grad_T_G(mesh, fespace, Wold)
Nb = fespace.Nb;
Nlb = fespace.Nlb;
rows = zeros(mesh.Ne*Nlb*Nlb,1);
cols = rows;
val = rows;
flag = 1;
for n = 1:mesh.Ne
    V = mesh.node(mesh.elem(n,:),:);
    [int_points_loc, int_weights_loc] = integral_loc(V, "2d");
    phi = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "x");
    phix = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "dx");
    phiy = basis_loc(V, int_points_loc(:,1), int_points_loc(:,2), fespace.basis_type, "dy");
    w3x = phix * Wold(fespace.elem(n,:));
    w3y = phiy * Wold(fespace.elem(n,:));
    for i = 1:Nlb
        for j = 1:Nlb
            f1 = w3y.*phix(:,j).*phi(:,i) - w3x.*phiy(:,j).*phi(:,i);
            r1 = int_weights_loc * f1;
            rows(flag) = fespace.elem(n,i);
            cols(flag) = fespace.elem(n,j);
            val(flag) = r1;
            flag = flag + 1;
        end
    end
end
matrix_A = sparse(rows, cols, val, Nb, Nb);
end